import { hex2dec } from './constant'

export function hexToU8(data: string): Uint8Array {
  const length = data.length / 2
  const u8 = new Uint8Array(length)

  for (let i = 0; i < length; i++) {
    u8[i] = hex2dec[data.slice(i * 2, (i * 2) + 2)]
  }
  return u8
}
